
package model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


@Entity
@Table(name = "ITEM")
@NamedQueries({
	@NamedQuery(name = "Item.findByItemid", query = "SELECT i FROM Item i WHERE i.id = :id"), 
	@NamedQuery(name = "Item.findByProductid", query = "SELECT i FROM Item i WHERE i.productid = :productid"), 
	@NamedQuery(name = "Item.findByName", query = "SELECT i FROM Item i WHERE i.name = :name"), 
	@NamedQuery(name = "Item.findByDescription", query = "SELECT i FROM Item i WHERE i.description = :description"), 
	@NamedQuery(name = "Item.findByImageurl", query = "SELECT i FROM Item i WHERE i.imageurl = :imageurl"), 
	@NamedQuery(name = "Item.findByImagethumburl", query = "SELECT i FROM Item i WHERE i.imagethumburl = :imagethumburl"), 
	@NamedQuery(name = "Item.findByPrice", query = "SELECT i FROM Item i WHERE i.price = :price")
	})
public class Item implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ITEMID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    @Column(name = "PRODUCTID")
    private int productid;
    @Column(name = "NAME")
    private String name;
    @Column(name = "DESCRIPTION")
    private String description;
    @Column(name = "IMAGEURL")
    private String imageurl;
    @Column(name = "IMAGETHUMBURL")
    private String imagethumburl;
    @Column(name = "PRICE")
    private double price;

    public Item() {
        this.name = "noname";
        this.description = "nodesc";
        this.price = 0.0;
    }

 
    public int getId() {
        return id;
    }

    public void setId(int itemid) {
        this.id = itemid;
    }

    public int getProductid() {
        return productid;
    }

    public void setProductid(int productid) {
        this.productid = productid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getImageurl() {
        return imageurl;
    }

    public void setImageurl(String imageurl) {
        this.imageurl = imageurl;
    }

    public String getImagethumburl() {
        return imagethumburl;
    }

    public void setImagethumburl(String imagethumburl) {
        this.imagethumburl = imagethumburl;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public int hashCode() {
        return id;
    }

    @Override
	public String toString() {
		return "Item [id=" + id + ", productid=" + productid + ", name=" + name
				+ ", description=" + description + ", imageurl=" + imageurl
				+ ", imagethumburl=" + imagethumburl + ", price=" + price + "]";
	}


	@Override
    public boolean equals(Object object) {
        if (!(object instanceof Item)) {
            return false;
        }
        Item other = (Item) object;
        return other.id==id;
    }



}
